// Copyright (C) 2020  Matthew "strager" Glazar
// See end of file for extended copyright information.

#ifndef QUICK_LINT_JS_TRANSLATION_TABLE_GENERATED_H
#define QUICK_LINT_JS_TRANSLATION_TABLE_GENERATED_H

// This file is **GENERATED** by tools/compile-translations.go.

#include <cstddef>
#include <cstdint>
#include <iterator>
#include <quick-lint-js/assert.h>
#include <quick-lint-js/consteval.h>
#include <quick-lint-js/hash-fnv.h>
#include <quick-lint-js/translation-table.h>
#include <string_view>

namespace quick_lint_js {
using namespace std::literals::string_view_literals;

constexpr std::uint32_t translation_table_locale_count = 4;
constexpr std::uint16_t translation_table_mapping_table_size = 260;
constexpr std::size_t translation_table_string_table_size = 48812;
constexpr std::size_t translation_table_locale_table_size = 24;

QLJS_CONSTEVAL std::uint16_t translation_table_const_hash_table_look_up(
    std::string_view untranslated) {
  struct const_hash_entry {
    std::uint16_t mapping_table_index;
    const char* untranslated;
  };

  // clang-format off
  constexpr const_hash_entry const_hash_table[] = {
          {0, ""},
          {40, "a function statement is not allowed as the body of {1:singular}"},
          {227, "unexpected 'finally' without 'try'"},
          {0, ""},
          {178, "missing parentheses around left-hand side of '**'"},
          {55, "break can only be used inside of a loop or switch"},
          {0, ""},
          {24, "'{0}' operator cannot be used before '**' without parentheses"},
          {94, "expected expression before newline"},
          {223, "unexpected '\\' in identifier"},
          {0, ""},
          {0, ""},
          {100, "expected variable name for 'import'-'as'"},
          {217, "unclosed object literal; expected '}'"},
          {0, ""},
          {28, "C-style for loop is missing its third component"},
          {79, "depth limit exceeded"},
          {117, "generator function '*' belongs before function name"},
          {57, "cannot assign to loop variable in for of/in loop"},
          {210, "this {0} looks fishy"},
          {0, ""},
          {245, "unopened block comment"},
          {0, ""},
          {68, "character is not allowed in identifiers"},
          {43, "an 'if' statement"},
          {169, "missing initializer in const declaration"},
          {203, "return statement returns nothing (undefined)"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {13, "'await' cannot be followed by an arrow function; use 'async' instead"},
          {44, "another invalid string, do not use outside benchmark"},
          {0, ""},
          {26, "BigInt literal contains decimal point"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {65, "cannot import variable named keyword '{0}'"},
          {187, "missing variable name"},
          {0, ""},
          {0, ""},
          {99, "expected variable name for 'catch'"},
          {97, "expected parameter for arrow function, but got a literal instead"},
          {241, "unicode byte order mark (BOM) cannot appear before #! at beginning of script"},
          {0, ""},
          {209, "switch statement needs parentheses around condition"},
          {145, "missing arrow operator for arrow function"},
          {143, "missing 'if' after 'else'"},
          {72, "code point in Unicode escape sequence must not be greater than U+10FFFF"},
          {81, "do-while loop needs parentheses around condition"},
          {213, "unclosed block comment"},
          {154, "missing body for try statement"},
          {208, "switch statement is missing '{1}' around condition"},
          {0, ""},
          {201, "redundant delete statement on variable"},
          {130, "invalid lone literal in object literal"},
          {70, "classes cannot be named 'await' in async function"},
          {0, ""},
          {0, ""},
          {194, "octal literal may not have decimal"},
          {239, "unexpected token in export; expected 'export default ...' or 'export {{name}' or 'export * from ...' or 'export class' or 'export function' or 'export let'"},
          {174, "missing name or parentheses for function"},
          {16, "'else' has no corresponding 'if'"},
          {75, "commas are not allowed between class methods"},
          {0, ""},
          {0, ""},
          {258, "{0} with no bindings"},
          {0, ""},
          {39, "a class statement is not allowed as the body of {1:singular}"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {10, "'>' is not allowed directly in JSX text; write {{'>'} or &gt; instead"},
          {104, "exporting requires '{{' and '}'"},
          {0, ""},
          {218, "unclosed regexp literal"},
          {162, "missing condition for switch statement"},
          {27, "BigInt literal contains exponent"},
          {67, "cannot update variable with '{0}' while declaring it"},
          {172, "missing name of exported class"},
          {0, ""},
          {30, "JSON syntax error"},
          {9, "'=' changes variables; to compare, use '===' instead"},
          {77, "const variable declared here"},
          {243, "unmatched indexing bracket"},
          {59, "cannot declare 'yield' inside generator function"},
          {3, "\"globals\" descriptor \"shadowable\" property must be a boolean"},
          {0, ""},
          {254, "while loop is missing '{1}' around condition"},
          {231, "unexpected characters in number literal"},
          {0, ""},
          {255, "while loop needs parentheses around condition"},
          {159, "missing comma between object literal entries"},
          {0, ""},
          {232, "unexpected characters in octal literal"},
          {106, "for loop needs an iterable, or condition and update clauses"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {76, "const fields within classes are only allowed in TypeScript, not JavaScript"},
          {86, "existing variable declared here"},
          {238, "unexpected token"},
          {153, "missing body for function"},
          {0, ""},
          {1, "\"global-groups\" entries must be strings"},
          {53, "attribute has wrong capitalization; write '{1}' instead"},
          {73, "code point out of range"},
          {105, "extra ',' is not allowed between function call arguments"},
          {166, "missing for loop header"},
          {38, "a 'with' statement"},
          {0, ""},
          {0, ""},
          {0, ""},
          {257, "with statement needs parentheses around expression"},
          {113, "function declared here"},
          {214, "unclosed class; expected '}' by end of file"},
          {11, "'?' creates a conditional expression"},
          {5, "\"globals\" descriptor must be a boolean or an object"},
          {32, "RegExp literal flags cannot contain Unicode escapes"},
          {45, "array started here"},
          {176, "missing operator between expression and arrow function"},
          {175, "missing operand for operator"},
          {127, "invalid expression left of assignment"},
          {242, "unmatched '}'"},
          {51, "assignment to imported variable"},
          {41, "a lexical declaration is not allowed as the body of {1:singular}"},
          {119, "hex number literal has no digits"},
          {0, ""},
          {0, ""},
          {90, "expected 'from \"name_of_module.mjs\"'"},
          {0, ""},
          {0, ""},
          {115, "functions/methods should not have '=>'"},
          {7, "'**' operator cannot be used after unary '{1}' without parentheses"},
          {192, "number literal contains trailing underscore(s)"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {200, "redeclaration of variable: {0}"},
          {226, "unexpected 'default' outside switch statement"},
          {25, "'}' is not allowed directly in JSX text; write {{'}'} instead"},
          {0, ""},
          {246, "use 'while' instead to loop until a condition is false"},
          {0, ""},
          {29, "C-style for loops have only three semicolon-separated components"},
          {207, "stray comma in let statement"},
          {132, "label named 'await' not allowed in async function"},
          {134, "legacy octal literals may not contain underscores"},
          {168, "missing header and body for 'for' loop"},
          {230, "unexpected characters in hex literal"},
          {128, "invalid function parameter"},
          {202, "remove '{0}' to update an existing variable"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {185, "missing semicolon between init and condition parts of for loop"},
          {0, ""},
          {89, "expected 'as' between '{1}' and '{2}'"},
          {78, "continue can only be used inside of a loop"},
          {156, "missing body for {1:headlinese}"},
          {0, ""},
          {0, ""},
          {229, "unexpected characters in binary literal"},
          {22, "'{0}' found here"},
          {136, "methods should not use the 'function' keyword"},
          {21, "'with' statement"},
          {56, "cannot access private identifier outside class"},
          {177, "missing parameters for arrow function"},
          {198, "private properties are not allowed in object literals"},
          {63, "cannot export variable named keyword '{0}'"},
          {235, "unexpected identifier in expression; missing operator before"},
          {71, "classes cannot be named 'let'"},
          {204, "see here"},
          {196, "octal number literal has no digits"},
          {191, "number literal contains consecutive underscores"},
          {0, ""},
          {250, "variable assigned before its declaration"},
          {251, "variable declared here"},
          {0, ""},
          {92, "expected '{{'"},
          {111, "function call started here"},
          {122, "imported variable declared here"},
          {0, ""},
          {54, "binary number literal has no digits"},
          {163, "missing condition for while statement"},
          {244, "unmatched parenthesis"},
          {236, "unexpected literal in parameter list; expected parameter name"},
          {0, ""},
          {0, ""},
          {98, "expected parameter for arrow function, but got an expression instead"},
          {170, "missing name in function statement"},
          {171, "missing name of class"},
          {0, ""},
          {0, ""},
          {179, "missing parentheses around operand of '{0}'"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {157, "missing catch or finally clause for try statement"},
          {0, ""},
          {165, "missing expression between parentheses"},
          {12, "'async static' is not allowed; write 'static async' instead"},
          {102, "expected {1:singular}"},
          {0, ""},
          {237, "unexpected statement before first switch case, expected 'case' or 'default'"},
          {195, "octal literal may not have exponent"},
          {4, "\"globals\" descriptor \"writable\" property must be a boolean"},
          {114, "function starts here"},
          {0, ""},
          {112, "function called before declaration in block scope: {0}"},
          {93, "expected expression after 'case'"},
          {47, "assigning to 'async' in a for-of loop requires parentheses"},
          {146, "missing body for 'for' loop"},
          {0, ""},
          {211, "this {1} looks fishy"},
          {131, "keywords cannot contain escape sequences"},
          {87, "expected ')' to close function call"},
          {0, ""},
          {0, ""},
          {18, "'if' statement"},
          {95, "expected expression before semicolon"},
          {173, "missing name of exported function"},
          {20, "'while' loop"},
          {189, "new variable shadows existing variable"},
          {125, "integer cannot be represented and will be rounded to '{1}'"},
          {193, "object literal started here"},
          {0, ""},
          {149, "missing body for catch clause"},
          {0, ""},
          {0, ""},
          {0, ""},
          {133, "legacy octal literal may not be BigInt"},
          {14, "'await' is only allowed in async functions"},
          {0, ""},
          {0, ""},
          {155, "missing body for while loop"},
          {0, ""},
          {120, "if statement is missing '{1}' around condition"},
          {138, "missing ',' between variable declarations"},
          {181, "missing property name after '.' operator"},
          {0, ""},
          {247, "use of undeclared type: {0}"},
          {19, "'in' disallowed in C-style for loop initializer"},
          {0, ""},
          {0, ""},
          {80, "do-while loop is missing '{1}' around condition"},
          {182, "missing property name between '.' and '.'"},
          {62, "cannot export variable named 'let'"},
          {161, "missing condition for if statement"},
          {37, "a 'while' loop"},
          {0, ""},
          {167, "missing function parameter list"},
          {33, "TypeScript's 'enum' feature is not yet implemented by quick-lint-js"},
          {83, "escaped character is not allowed in identifiers"},
          {252, "variable used before declaration: {0}"},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {0, ""},
          {188, "misspelled React attribute; write '{1}' instead"},
          {144, "missing 'while (condition)' for do-while statement"},
          {220, "unclosed template"},
          {0, ""},
          {0, ""},
          {109, "forwarding exports are only allowed in export-from"},
          {66, "cannot reference private variables without object; use 'this.'"},
          {0, ""},
          {140, "missing ':' in conditional expression"},
          {150, "missing body for class"},
          {0, ""},
          {0, ""},
          {36, "a 'for' loop"},
          {233, "unexpected control character"},
          {234, "unexpected expression; missing key for object entry"},
          {0, ""},
          {0, ""},
          {224, "unexpected 'case' outside switch statement"},
          {0, ""},
          {0, ""},
          {0, ""},
          {85, "event attributes must be camelCase: '{1}'"},
          {23, "'{0}' is not allowed for strings; use {1} instead"},
          {42, "a {{0} b }} c"},
          {6, "\"globals\" must be an object"},
          {82, "do-while statement starts here"},
          {110, "free {1} and {0} {1} {2}"},
          {0, ""},
          {0, ""},
          {222, "unexpected '@'"},
          {107, "for-in loop expression cannot have semicolons"},
          {216, "unclosed identifier escape sequence"},
          {240, "unexpected token in variable declaration; expected variable name"},
          {0, ""},
          {34, "TypeScript's 'interface' feature is not allowed in JavaScript code"},
          {60, "cannot declare and export variable with 'export default'"},
          {2, "\"global-groups\" must be a boolean or an array"},
          {164, "missing end of array; expected ']'"},
          {148, "missing body for 'switch' statement"},
          {101, "expected {1:headlinese}"},
          {61, "cannot declare variable named keyword '{0}'"},
          {50, "assignment to const variable before its declaration"},
          {108, "for-of loop expression cannot have semicolons"},
          {215, "unclosed code block; expected '}' by end of file"},
          {206, "stray comma in function parameter"},
          {158, "missing catch variable name between parentheses"},
          {152, "missing body for finally clause"},
          {0, ""},
          {249, "variable already declared here"},
          {91, "expected 'from' before module specifier"},
          {199, "redeclaration of global variable"},
          {0, ""},
          {0, ""},
          {0, ""},
          {121, "if statement needs parentheses around condition"},
          {219, "unclosed string literal"},
          {64, "cannot import 'let'"},
          {88, "expected ',' between object literal entries"},
          {118, "here"},
          {0, ""},
          {8, "'.' operator needs a key name; use + to concatenate strings; use [] to access with a dynamic key"},
          {103, "exporting requires 'default'"},
          {74, "commas are not allowed after spread parameter"},
          {151, "missing body for do-while loop"},
          {124, "indexing requires an expression"},
          {0, ""},
          {197, "opening '<{1}>' tag here"},
          {46, "arrow is here"},
          {48, "assignment to const global variable"},
          {123, "incomplete export; expected 'export default ...' or 'export {{name}' or 'export * from ...' or 'export class' or 'export function' or 'export let'"},
          {253, "what is this '{1}' nonsense?"},
          {0, ""},
          {137, "mismatched JSX tags; expected '</{1}>'"},
          {126, "invalid UTF-8 sequence"},
          {15, "'do-while' loop"},
          {0, ""},
          {0, ""},
          {141, "missing '<>' and '</>' to enclose multiple children"},
          {142, "missing '=' after variable"},
          {183, "missing semicolon after statement"},
          {0, ""},
          {0, ""},
          {0, ""},
          {116, "generator function '*' belongs after keyword function"},
          {31, "React/JSX is not yet implemented"},
          {259, "~~~ invalid string, do not use outside benchmark ~~~"},
          {212, "try statement starts here"},
          {186, "missing value for object property"},
          {0, ""},
          {0, ""},
          {248, "use of undeclared variable: {0}"},
          {180, "missing parentheses around self-invoked function"},
          {0, ""},
          {0, ""},
          {147, "missing body for 'if' statement"},
          {256, "with statement is missing '{1}' around expression"},
          {221, "unexpected '#'"},
          {0, ""},
          {35, "a 'do-while' loop"},
          {84, "escaping '-' is not allowed in tag names; write '-' instead"},
          {190, "newline is not allowed between 'async' and arrow function parameter list"},
          {0, ""},
          {96, "expected hexadecimal digits in Unicode escape sequence"},
          {184, "missing semicolon between condition and update parts of for loop"},
          {49, "assignment to const variable"},
          {160, "missing comparison; '{1}' does not extend to the right side of '{0}'"},
          {129, "invalid hex escape sequence: {0}"},
          {225, "unexpected 'catch' without 'try'"},
          {0, ""},
          {58, "cannot declare 'await' inside async function"},
          {0, ""},
          {0, ""},
          {17, "'for' loop"},
          {139, "missing '...' in JSX attribute spread"},
          {228, "unexpected '{0}'"},
          {0, ""},
          {52, "assignment to undeclared variable"},
          {69, "children end here"},
          {135, "let statement cannot declare variables named 'let'"},
          {205, "something happened"},
  };
  // clang-format on

  std::uint64_t hash = hash_fnv_1a_64(untranslated, 14695981039346657544ULL);
  std::uint64_t table_size = 389;
  for (std::uint64_t attempt = 0; attempt <= 4; ++attempt) {
    const const_hash_entry& hash_entry =
        const_hash_table[(hash + attempt * attempt) % table_size];
    if (hash_entry.mapping_table_index == 0) {
      break;
    }
    if (hash_entry.untranslated == untranslated) {
      return hash_entry.mapping_table_index;
    }
  }

  // If you see an error with the following line, translation-table-generated.h
  // is out of date. Run tools/update-translator-sources to rebuild this file.
  QLJS_CONSTEXPR_ASSERT(false);

  return 0;
}
}

#endif

// quick-lint-js finds bugs in JavaScript programs.
// Copyright (C) 2020  Matthew "strager" Glazar
//
// This file is part of quick-lint-js.
//
// quick-lint-js is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// quick-lint-js is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with quick-lint-js.  If not, see <https://www.gnu.org/licenses/>.
